#ifndef __CONTROL_H
#define __CONTROL_H


#include "tim.h"
#include "trace.h"


#define   L_MOTOR_TIM      htim2
#define   L1_CHANNEL_1     TIM_CHANNEL_1
#define   L1_CHANNEL_2     TIM_CHANNEL_2
#define   L2_CHANNEL_1     TIM_CHANNEL_3
#define   L2_CHANNEL_2     TIM_CHANNEL_4

#define   R_MOTOR_TIM      htim8
#define   R1_CHANNEL_1     TIM_CHANNEL_1
#define   R1_CHANNEL_2     TIM_CHANNEL_2
#define   R2_CHANNEL_1     TIM_CHANNEL_3
#define   R2_CHANNEL_2     TIM_CHANNEL_4
#define   PWM_MAX        9999


typedef enum
{
	l1 = 0,
	l2 = 1,
	r1 = 2,
	r2 = 3
}wheel;


typedef enum
{
	run = 1,
	stop = 0
}wheelStatus;



void MotorInit();
// SetSpeed      0 <= speed < PWM_MAX
void SetSpeed(wheel w, int speed, wheelStatus status);
void SetPWM(wheel w, TIM_HandleTypeDef* motorTim, uint32_t motorTimChannel1, uint32_t motorTimChannel2, int speed, wheelStatus status);
void GoFront(int speed, pos s);
void GoBehind(int speed, pos s);
void GoLeft(int speed, pos s);
void GoRight(int speed, pos s);
void GoStop(void);

void GoTurnLeft(int speed);
void GoTurnRight(int speed);


#endif
